package com.hknc.btscale.view;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.fragment.app.Fragment;

import com.bumptech.glide.Glide;
import com.hknc.btscale.MainActivity;
import com.hknc.btscale.R;

public class BannerFragment extends Fragment {
    private static final String POSITION = "position";

    public static BannerFragment newInstance(int position, String strings) {
        BannerFragment fragment = new BannerFragment();
        Bundle args = new Bundle();
        args.putString("imgurl", strings);
        args.putInt(POSITION, position);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        //imageview
        View view = inflater.inflate(R.layout.img, container, false);
        ImageView img = view.findViewById(R.id.img);
        Glide.with(getContext())
                .load(getArguments().getString("imgurl"))
                .fallback(R.drawable.touming)
                .into(img);
//            img.setScaleType(ImageView.ScaleType.);

        return view;
    }
}